package com.petshop.transactionrecords.service.impl;

import java.util.List;

import com.petshop.products.mapper.PetProductsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.petshop.transactionrecords.mapper.PetTransactionrecordsMapper;
import com.petshop.transactionrecords.domain.PetTransactionrecords;
import com.petshop.transactionrecords.service.IPetTransactionrecordsService;

/**
 * 交易记录Service业务层处理
 *
 * @author ruoyi
 * @date 2024-09-12
 */
@Service
public class PetTransactionrecordsServiceImpl implements IPetTransactionrecordsService
{
    @Autowired
    private PetTransactionrecordsMapper petTransactionrecordsMapper;
    @Autowired
    private PetProductsMapper petProductsMapper;

    /**
     * 查询交易记录
     *
     * @param transactionID 交易记录主键
     * @return 交易记录
     */
    @Override
    public PetTransactionrecords selectPetTransactionrecordsByTransactionID(Long transactionID)
    {
        return petTransactionrecordsMapper.selectPetTransactionrecordsByTransactionID(transactionID);
    }

    /**
     * 查询交易记录列表
     *
     * @param petTransactionrecords 交易记录
     * @return 交易记录
     */
    @Override
    public List<PetTransactionrecords> selectPetTransactionrecordsList(PetTransactionrecords petTransactionrecords)
    {
        return petTransactionrecordsMapper.selectPetTransactionrecordsList(petTransactionrecords);
    }

    /**
     * 新增交易记录
     *
     * @param petTransactionrecords 交易记录
     * @return 结果
     */
    @Override
    public int insertPetTransactionrecords(PetTransactionrecords petTransactionrecords)
    {
        petProductsMapper.updatePetProductsByTransactionrecordProductName(petTransactionrecords);
        return petTransactionrecordsMapper.insertPetTransactionrecords(petTransactionrecords);
    }

    /**
     * 修改交易记录
     *
     * @param petTransactionrecords 交易记录
     * @return 结果
     */
    @Override
    public int updatePetTransactionrecords(PetTransactionrecords petTransactionrecords)
    {
        return petTransactionrecordsMapper.updatePetTransactionrecords(petTransactionrecords);
    }

    /**
     * 批量删除交易记录
     *
     * @param transactionIDs 需要删除的交易记录主键
     * @return 结果
     */
    @Override
    public int deletePetTransactionrecordsByTransactionIDs(Long[] transactionIDs)
    {
        return petTransactionrecordsMapper.deletePetTransactionrecordsByTransactionIDs(transactionIDs);
    }

    /**
     * 删除交易记录信息
     *
     * @param transactionID 交易记录主键
     * @return 结果
     */
    @Override
    public int deletePetTransactionrecordsByTransactionID(Long transactionID)
    {
        return petTransactionrecordsMapper.deletePetTransactionrecordsByTransactionID(transactionID);
    }
}
